import { Controller, Post, UploadedFile, UseInterceptors } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Public } from 'src/common/guards';
import { FileInterceptor } from '@nestjs/platform-express';

@ApiTags('上传接口')
@Controller()
export class UploadController {
  constructor(
  ) { }
  @Public()
  @Post('upload')
  @UseInterceptors(FileInterceptor('file'))
  uploadFile(@UploadedFile() file: Express.Multer.File) {
    const data = `/${file.destination.split('/').splice(2, 2).join('/')}/${file.filename}`
    console.log('file', file);

    return {
      message: '上传成功',
      data: data,
    };
  }
}
